package com.yanfan.passengerFlow.controller;

import java.util.Arrays;
import java.util.List;
import javax.validation.Valid;
import javax.servlet.http.HttpServletResponse;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.passengerFlow.domain.IbmsPassengerFlowStatisticsDevices;
import com.yanfan.passengerFlow.service.IIbmsPassengerFlowStatisticsDevicesService;
import com.yanfan.common.utils.poi.ExcelUtil;
import com.yanfan.common.core.page.TableDataInfo;

/**
 * 客流统计设备Controller
 *
 * @author genluo
 * @date 2024-08-26
 */
@Api(tags = "客流统计设备")
@RestController
@RequestMapping("/passengerFlow/passengerFlowStatisticsDevices")
public class IbmsPassengerFlowStatisticsDevicesController extends BaseController {
    @Autowired
    private IIbmsPassengerFlowStatisticsDevicesService ibmsPassengerFlowStatisticsDevicesService;

    /**
     * 查询客流统计设备列表
     */
    @ApiOperation("客流统计设备分页列表")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatisticsDevices:list')")
    @GetMapping("/list")
    public TableDataInfo list(IbmsPassengerFlowStatisticsDevices ibmsPassengerFlowStatisticsDevices) {
        startPage();
        List<IbmsPassengerFlowStatisticsDevices> list = ibmsPassengerFlowStatisticsDevicesService.selectIbmsPassengerFlowStatisticsDevicesList(ibmsPassengerFlowStatisticsDevices);
        return getDataTable(list);
    }

    /**
     * 导出客流统计设备列表
     */
    @ApiOperation("导出客流统计设备列表")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatisticsDevices:export')")
    @Log(title = "客流统计设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IbmsPassengerFlowStatisticsDevices ibmsPassengerFlowStatisticsDevices) {
        List<IbmsPassengerFlowStatisticsDevices> list = ibmsPassengerFlowStatisticsDevicesService.selectIbmsPassengerFlowStatisticsDevicesList(ibmsPassengerFlowStatisticsDevices);
        ExcelUtil<IbmsPassengerFlowStatisticsDevices> util = new ExcelUtil<IbmsPassengerFlowStatisticsDevices>(IbmsPassengerFlowStatisticsDevices.class);
        util.exportExcel(response, list, "客流统计设备数据");
    }

    /**
     * 获取客流统计设备详细信息
     */
    @ApiOperation("获取客流统计设备详细信息")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatisticsDevices:query')")
    @GetMapping(value = "/{deviceId}")
    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
        return success(ibmsPassengerFlowStatisticsDevicesService.getById(deviceId));
    }

    /**
     * 新增客流统计设备
     */
    @ApiOperation("新增客流统计设备")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatisticsDevices:add')")
    @Log(title = "客流统计设备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody IbmsPassengerFlowStatisticsDevices ibmsPassengerFlowStatisticsDevices) {
        return toAjax(ibmsPassengerFlowStatisticsDevicesService.save(ibmsPassengerFlowStatisticsDevices));
    }

    /**
     * 修改客流统计设备
     */
    @ApiOperation("修改客流统计设备")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatisticsDevices:edit')")
    @Log(title = "客流统计设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody IbmsPassengerFlowStatisticsDevices ibmsPassengerFlowStatisticsDevices) {
        return toAjax(ibmsPassengerFlowStatisticsDevicesService.updateById(ibmsPassengerFlowStatisticsDevices));
    }

    /**
     * 删除客流统计设备
     */
    @ApiOperation("删除客流统计设备")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatisticsDevices:remove')")
    @Log(title = "客流统计设备", businessType = BusinessType.DELETE)
    @DeleteMapping("/{deviceIds}")
    public AjaxResult remove(@PathVariable Long[] deviceIds) {
        return toAjax(ibmsPassengerFlowStatisticsDevicesService.removeBatchByIds(Arrays.asList(deviceIds)));
    }
}
